﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace LastoRevival.Service.Contracts.Models
{
	[DataContract]
	public class LoginAttemptResult
	{

		public Guid? LoginToken { get; private set; }
		public LoginResult Status { get; private set; }
		public DateTime? AuthenticatedUntil { get; private set; }

		public LoginAttemptResult(Guid loginToken, DateTime authenticatedUntil)
		{
			// if we have a token, we're successful, that's the rule
			this.Status = LoginResult.Success;
			this.LoginToken = loginToken;
			this.AuthenticatedUntil = authenticatedUntil;
		}

		public LoginAttemptResult(LoginResult status)
		{
			// sanity check
			if (status == LoginResult.Success)
			{
				throw new NotSupportedException("Token must be passed if login was successful");
			}

			this.Status = status;
		}

	}
}
